﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Manager;
using Model;
using ExtAspNet;
namespace HealthSystem.sysAdmin
{
    public partial class MergeHistory : BasePage
    {
        HW_SchoolMergeLogManager mergeLogManager = new HW_SchoolMergeLogManager();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGrid();
            }

        }
        private void BindGrid()
        {
            
            int count;
            if (actionbt.Text == "search")
            {
                DataTable dt = new DataTable();
               dt= mergeLogManager.Search(Grid1.PageIndex, Grid1.PageSize, out count, searchbox.Text.Trim());
               Grid1.RecordCount = count;
               Grid1.DataSource = dt;
               Grid1.DataBind();
            }
            else
            {
                DataTable dt = new DataTable();
                dt = mergeLogManager.GetList(Grid1.PageIndex, Grid1.PageSize, out count);
                Grid1.RecordCount = count;
                Grid1.DataSource = dt;
                Grid1.DataBind();
            }
           
        }
        protected void searchbox_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(searchbox.Text))
                actionbt.Text = "";
            else
            {
                Grid1.PageIndex = 0;
                actionbt.Text = "search";
                BindGrid();
            }
        }
        protected void Grid1_RowCommand(object sender, ExtAspNet.GridCommandEventArgs e)
        {
            string schoolcode = Grid1.Rows[e.RowIndex].DataKeys[0] as string;
            if (e.CommandName == "detail")
            {
                PageContext.RegisterStartupScript(Window1.GetShowReference("MergeDetail.aspx?schoolcode="+schoolcode,"学校合并详细信息"));
            }
        }
        protected void PageIndex_Changed(object sender, ExtAspNet.GridPageEventArgs e)
        {
            Grid1.PageIndex = e.NewPageIndex;
            BindGrid();
        }
        protected void Window1_Close(object sender,ExtAspNet.WindowCloseEventArgs e)
        {
            BindGrid();
        }
    }
}